/**
 * @description 实现路由管理
 */
import Vue from 'vue'
import Router from 'vue-router'
import Login from '../views/login'
import Home from '../views/home'
import ProductDetail from '../views/product/detail/index.vue'
import ProductEdit from '../views/product/edit/index.vue'
import ProductList from '../views/product/list/index.vue'

import SupplierList from '../views/supplier/list/index.vue'
import SupplierNew from '../views/supplier/new/index.vue'
import SupplierDetail from '../views/supplier/detail/index.vue'
import SupplierEdit from '../views/supplier/edit/index.vue'
import ShopList from '../views/shop/list/index.vue'
import ShopEdit from '../views/shop/edit/index.vue'
import ShopDetail from '../views/shop/detail/index.vue'
import ShelvesList from '../views/shop/shelves/list'

// import routes from './routes'
import interceptor from './interceptor'
// 全局插件注册--那么页面才可以使用路由的全局组件
Vue.use(Router)

const router = new Router({
    // 指定路由模式：mode
    // mode: 'history',
    // 配置路由
    routes: [
        { path: '/', redirect: '/login' },
        { path: '/login', component: Login, meta: { nologin: true, layout: 'BlankLayout' } },  
        { path: '/home', component: Home },
        // 产品管理路由
        { path: '/product/detail', component: ProductDetail },
        { path: '/product/edit', component: ProductEdit },
        { path: '/product/list', component: ProductList },
        // 采购管理路由
        { path: '/supplier/list', component: SupplierList },
        { path: '/supplier/new', component: SupplierNew },
        {path: '/supplier/detail', name:'Detail',component: SupplierDetail},
        {path:'/supplier/edit',name:'Edit',component:SupplierEdit},
        // 门店管理路由
        { path: '/shop/list', component: ShopList },
        { path: '/shop/edit', component: ShopEdit },
        { path: '/shop/detail', component: ShopDetail },
        {path:'/shop/shelves/list',component:ShelvesList}
    ]
})

// 注入拦截器
router.beforeEach(interceptor)
export default router